home *** CD-ROM | disk | FTP | other *** search
/ Programming Languages Suite / ProgramD2.iso / Visual Database / Visual BASIC 5.0 (Ent. Edition) / Vb5ent Extractor.EXE / VB / SAMPLES / COMPTOOL / ADDINS / TABORDER / TABORDER.BAS < prev    next >
Encoding:
BASIC Source File  |  1996-12-07  |  1.9 KB  |  53 lines

  1. Attribute VB_Name = "modMain"
  2. Option Explicit
  3.  
  4.  
  5. Private Declare Sub PostMessage Lib "user32" Alias "PostMessageA" (ByVal hwnd&, ByVal msg&, ByVal wp&, ByVal lp&)
  6. Private Declare Sub SetFocus Lib "user32" (ByVal hwnd&)
  7. Private Declare Function GetParent Lib "user32" (ByVal hwnd&) As Long
  8. Const WM_SYSKEYDOWN = &H104
  9. Const WM_SYSKEYUP = &H105
  10. Const WM_SYSCHAR = &H106
  11. Const VK_F = 70  ' VK_A thru VK_Z are the same as their ASCII equivalents: 'A' thru 'Z'
  12. Dim hwndMenu       As Long           'needed to pass the menu keystrokes to VB
  13.  
  14. Global gVBInstance  As VBIDE.VBE       'instance of VB IDE
  15. Global gwinWindow   As VBIDE.Window    'used to make sure we only run one instance
  16. Global gdocTabOrder As Object          'user doc object
  17.  
  18.  
  19. Declare Function WritePrivateProfileString& Lib "Kernel32" Alias "WritePrivateProfileStringA" (ByVal AppName$, ByVal KeyName$, ByVal keydefault$, ByVal FileName$)
  20. Global Const APP_CATEGORY = "Microsoft Visual Basic AddIns"
  21.  
  22. Sub AddToINI()
  23.   'this code adds an entry to VB5.INI
  24.   'this should be executed from the immediate window
  25.   Debug.Print WritePrivateProfileString("Add-Ins32", "TabOrder.Connect", "0", "vbaddin.ini")
  26. End Sub
  27.  
  28. Function InRunMode(VBInst As VBIDE.VBE) As Boolean
  29.   InRunMode = (VBInst.CommandBars("File").Controls(1).Enabled = False)
  30. End Function
  31.  
  32. Sub HandleKeyDown(ud As Object, KeyCode As Integer, Shift As Integer)
  33.   If Shift <> 4 Then Exit Sub
  34.   If KeyCode < 65 Or KeyCode > 90 Then Exit Sub
  35.   If gVBInstance.DisplayModel = vbext_dm_SDI Then Exit Sub
  36.   
  37.   If hwndMenu = 0 Then hwndMenu = FindHwndMenu(ud.hwnd)
  38.   PostMessage hwndMenu, WM_SYSKEYDOWN, KeyCode, &H20000000
  39.   KeyCode = 0
  40.   SetFocus hwndMenu
  41. End Sub
  42.  
  43. Function FindHwndMenu&(ByVal hwnd&)
  44.   Dim h As Long
  45.   
  46. Loop2:
  47.   h = GetParent(hwnd)
  48.   If h = 0 Then FindHwndMenu = hwnd: Exit Function
  49.   hwnd = h
  50.   GoTo Loop2
  51. End Function
  52.  
  53.